package com.itheima.web.controller.sms;

import com.itheima.common.core.model.AjaxResult;
import com.itheima.common.core.model.PageResult;
import com.itheima.service.sms.SmsCouponHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 优惠卷领取记录
 */
@RestController
@RequestMapping("couponHistory")
@Slf4j
public class CouponHistoryController {
    @DubboReference
    private SmsCouponHistoryService smsCouponHistoryService;

    /**
     * 根据优惠券id，使用状态，订单编号分页获取领取记录
     * @param orderSn
     * @param couponId
     * @param pageNum
     * @param pageSize
     * @param useStatus
     * @return
     */
    @GetMapping("list")
    public AjaxResult list(String orderSn,Integer couponId,Integer pageNum,Integer pageSize,Integer useStatus){
        log.info("分页查询条件：{},{},{},{},{}",orderSn,couponId,pageNum,pageSize,useStatus);
        PageResult pageResult=smsCouponHistoryService.selectAll(orderSn,couponId,pageNum,pageSize,useStatus);
        return AjaxResult.success("操作成功",pageResult);
    }
}
